﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Infinity.Models;

namespace Infinity.Areas.Managerial.Controllers
{
    public class LoginController : Controller
    {
        private InfinityEntities db = new InfinityEntities();

        //
        // GET: /Managerial/Login/

        //public ActionResult Index()
        //{
        //    return View(db.Users.ToList());
        //}

        ////
        //// GET: /Managerial/Login/Details/5

        //public ActionResult Details(int id = 0)
        //{
        //    Users users = db.Users.Find(id);
        //    if (users == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(users);
        //}

        //
        // GET: /Managerial/Login/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Managerial/Login/Create

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create(Users users)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(users);
                db.SaveChanges();
                return RedirectToAction("Index", "Instructor");
            }

            return View(users);
        }
        public JsonResult IsUserAvailable(string UserName)
        {
            return Json(!db.Users.Any(user => user.UserName ==UserName), JsonRequestBehavior.AllowGet);
        }

        //
        // GET: /Managerial/Login/Edit/5

        //public ActionResult Edit(int id = 0)
        //{
        //    Users users = db.Users.Find(id);
        //    if (users == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(users);
        //}

        ////
        //// POST: /Managerial/Login/Edit/5

        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(Users users)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(users).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    return View(users);
        //}

        ////
        //// GET: /Managerial/Login/Delete/5

        //public ActionResult Delete(int id = 0)
        //{
        //    Users users = db.Users.Find(id);
        //    if (users == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(users);
        //}

        ////
        //// POST: /Managerial/Login/Delete/5

        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        //public ActionResult DeleteConfirmed(int id)
        //{
        //    Users users = db.Users.Find(id);
        //    db.Users.Remove(users);
        //    db.SaveChanges();
        //    return RedirectToAction("Index");
        //}

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}